/*
 * Copyright (c) 2020, 2023, 3044483124@qq.com All rights reserved.
 *
 */
package cn.itcast;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;

/**
 * <p>Project: JavaStudy - Work4
 * <p>Powered by jiangbo On 2023-01-12
 * 15:19:25
 * <p>Created by IntelliJ IDEA
 *
 * @author jiangbo [3044483124@qq.com]
 * @version 1.0
 * @since 8/17
 */
public class Work4 {
    public static void main(String[] args) {
        try {
            FileOutputStream fos = new FileOutputStream("user.txt",true);
            for (int i = 0; i < 5000; i++) {
                fos.write(getStr(3, 15).getBytes());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public static String getStr(int a, int b) {
        StringBuilder su = new StringBuilder();
        su.append(getStr(true) + " ");
        Random rand = new Random();
        int len = rand.nextInt(b - a) + a;
        for (int i = 0; i < len; i++) {
            su.append(getStr() + " ");
        }
        return su.toString().trim().concat(".\n");
    }


    public static String getStr() {
        return getStr(false);
    }

    public static String getStr(boolean f) {
        Random rand = new Random();
        String s1 = "abcdefhijklmnopqrstuvwxyz";
        String s2 = "abcdefhijklmnopqrstuvwxyz".toUpperCase();
        StringBuilder su = new StringBuilder();
        if (f) {
            su.append(s2.charAt(rand.nextInt(s2.length())));
        }
        int len = rand.nextInt(5) + 2;
        for (int i = 0; i <= len; i++) {
            su.append(s1.charAt(rand.nextInt(s2.length())));
        }
        return su.toString();
    }
}


